from cassandra.cluster import Cluster, log

cluster = Cluster(['192.168.209.200'])
session = cluster.connect()
session.execute("use ks1")

exe1 = session.execute_async("select * from users")

#处理结果
def log_results(results):
     for rows in results:
         for r in rows:
             print(r)
#处理异常
def log_error(exc):
     log.error("Operation failed: %s", exc)
     print("Operation failed: %s", exc)

exe1.add_callbacks(log_results, log_error)
try:
     results = exe1.result()
except Exception:
     log.exception("Operation failed:")



session.shutdown()
cluster.shutdown()

'''
官方文档
https://docs.datastax.com/en/developer/python-driver/3.29/index.html
'''




